#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    const int maxn=100050;
    int a[maxn];
    int wrongnum=0;
    int num;
    for(int i=0;i<N;i++){
	cin>>num;
	a[num]=i;
	if(a[i]!=i){
	    wrongnum++;
	}
    }
    int swaptimes=0;
    int k=1;
    while(wrongnum>0){
	if(a[0]==0){
	    while(k<N){
		if(a[k]!=k){//find the wrong num
		    swap(a[0],a[k]);
		    k=1;
		    swaptimes++;
		    break;
		}
		k++;
	    }
	}
	while(a[0]!=0){//case2:0 isn't on the correct position
	    swap(a[0],a[a[0]]);//Swap
	    wrongnum--;
	    swaptimes++;
	}
    }
    cout<<swaptimes<<endl;
}
